
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 08/31/2012 09:37:09
-- Generated from EDMX file: C:\Cources\Testing\Testing\PersonTest.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [test];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------


-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------


-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'Tests'
CREATE TABLE [dbo].[Tests] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [bla] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'TestChilds'
CREATE TABLE [dbo].[TestChilds] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [POpa] nvarchar(max)  NOT NULL,
    [TestId] int  NOT NULL
);
GO

-- Creating table 'TestChild2'
CREATE TABLE [dbo].[TestChild2] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Piska] nvarchar(max)  NOT NULL,
    [TestId] int  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'Tests'
ALTER TABLE [dbo].[Tests]
ADD CONSTRAINT [PK_Tests]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'TestChilds'
ALTER TABLE [dbo].[TestChilds]
ADD CONSTRAINT [PK_TestChilds]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'TestChild2'
ALTER TABLE [dbo].[TestChild2]
ADD CONSTRAINT [PK_TestChild2]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [TestId] in table 'TestChilds'
ALTER TABLE [dbo].[TestChilds]
ADD CONSTRAINT [FK_TestTestChild]
    FOREIGN KEY ([TestId])
    REFERENCES [dbo].[Tests]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_TestTestChild'
CREATE INDEX [IX_FK_TestTestChild]
ON [dbo].[TestChilds]
    ([TestId]);
GO

-- Creating foreign key on [TestId] in table 'TestChild2'
ALTER TABLE [dbo].[TestChild2]
ADD CONSTRAINT [FK_TestTestChild2]
    FOREIGN KEY ([TestId])
    REFERENCES [dbo].[Tests]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_TestTestChild2'
CREATE INDEX [IX_FK_TestTestChild2]
ON [dbo].[TestChild2]
    ([TestId]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------